home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.02 Feb 90 / FuzzyBrush source / DrawEffect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-01  |  1.6 KB  |  80 lines  |  [TEXT/KAHL]

  1. /*
  2.  *  DrawEffect.c
  3.  *    Linda McLennan
  4.  *  COPYRIGHT © 1989 Ventana Software
  5. */
  6.  
  7. #include    "BWit.h"
  8. #include    "Fuzzy.h"
  9.  
  10. DrawEffect( tDataPtr, fzDataHandle )
  11.  
  12.     ToolDataPtr            tDataPtr;
  13.     FuzzyDataHandle        fzDataHandle;
  14.         
  15. {
  16.     GrafPtr            dPort;
  17.     short            n, theEffect;
  18.     short            halfSize, numPts;
  19.     Point            offset;
  20.     FuzzyDataPtr    fzDataPtr;
  21.  
  22.     HLock( fzDataHandle );
  23.     fzDataPtr = *fzDataHandle;
  24.     theEffect = fzDataPtr->whichEffect;
  25.     if ( theEffect == crosshatch )
  26.         numPts = 1;        
  27.     else
  28.         numPts = 8;
  29.         
  30.     halfSize = (fzDataPtr->brushSize)/2;    
  31.  
  32.     for ( n = 1; n <= numPts; n++ )
  33.     {
  34.         /* get random offset from current */
  35.         /* mouse within size of brush */
  36.         offset.h = Random() % halfSize;
  37.         offset.v = Random() % halfSize;
  38.     
  39.         switch( theEffect )
  40.         {
  41.             case fuzzy:        
  42.                 MoveTo( tDataPtr->newPoint.h,
  43.                         tDataPtr->newPoint.v );
  44.                 Line( offset.h, offset.v);
  45.                 break;
  46.  
  47.             case furry:        
  48.                 MoveTo( tDataPtr->newPoint.h + offset.h,
  49.                         tDataPtr->newPoint.v + offset.v );
  50.                 Line( offset.h, offset.v);
  51.                 break;
  52.  
  53.             case crosshatch:        
  54.                 MoveTo( tDataPtr->newPoint.h + offset.h,
  55.                         tDataPtr->newPoint.v + offset.v );
  56.                 Line( 7, 0);
  57.                 MoveTo( tDataPtr->newPoint.h + offset.h + 1,
  58.                         tDataPtr->newPoint.v + offset.v - 2);
  59.                 Line( 6, 6 );
  60.                 break;
  61.         }
  62.     }
  63.  
  64.     HLock( fzDataHandle );
  65.  
  66.     /* compute update area and add pen size */
  67.     Pt2Rect(tDataPtr->oldPoint, tDataPtr->newPoint,
  68.             &tDataPtr->updateRect );
  69.     InsetRect( &tDataPtr->updateRect,
  70.         -halfSize, -halfSize );
  71.  
  72.     if ( theEffect == furry )
  73.         InsetRect( &tDataPtr->updateRect,
  74.             -halfSize, -halfSize );
  75.         
  76.     GetPort( &dPort );
  77.     tDataPtr->updateRect.right += dPort->pnSize.h;
  78.     tDataPtr->updateRect.bottom += dPort->pnSize.v;
  79.  }
  80.